import React from "react";
import { Form, Input, Button } from "antd-mobile";
import { doLogin } from "services/login";
const MyLogin = () => {
  const handleFinish = (vals: any) => {
    doLogin(vals).then((res: any) => {
      const { doctorId, sessionId } = res?.result || {};
      if (doctorId && sessionId) {
        localStorage.setItem("doctorId", doctorId);
        localStorage.setItem("sessionId", sessionId);
      }
    });
  };

  return (
    <div>
      <Form
        layout="horizontal"
        footer={
          <Button block color="primary" type="submit">
            登录
          </Button>
        }
        onFinish={handleFinish}
      >
        <Form.Item name={"email"}>
          <Input placeholder="email" />
        </Form.Item>
        <Form.Item name={"pwd"}>
          <Input placeholder="pwd" />
        </Form.Item>
      </Form>
    </div>
  );
};

export default MyLogin;